(function (fruit, util, global) {

    fruit.ui.define("fruit.ui.HTMLLoader", {
        events:["Append"],
        view: {

        },
        properties: {
            url: {
                getter:function(){
                    return this._url;
                },
                setter:function(value){
                    this._url = value;
                    if (value) {
                        this.load(value);
                    }
                }
            }
        },
        methods: {
            load: function (url) {
                var self = this;
                fruit.http.ajax({
                    url: url,
                    dataType: 'html',
                    success: function (data) {
                        self.success(data);
                    },
                    error: function (args) {
                        self.error(args);
                    }
                })
            },
            success: function (data) {
               //todo fix
               var htmlString = "<div>"+data+"</div>";
               this.appendChild(fruit.ui.Element.resolve(fruit.dom.createElement(htmlString)));
               this.fire("Append");
            },
            error: function (args) {

            }
        }
    });
})(fruit, fruit.util, fruit.global);
